﻿#region 참조 네임스페이스

using System;
using System.Windows.Forms;
using Skying.Windows.Hook;

#endregion

namespace MouseHooker
{
	public partial class MainForm : Form
	{
		#region 생성자/소멸자

		public MainForm()
		{
			this.InitializeComponent();
		}

		#endregion

		#region 버튼 이벤트

		/// <summary>
		/// Start 버튼이 클릭됐을 때 발생하는 이벤트를 구현한다.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void StartButton_Click(object sender, EventArgs e)
		{
			HookBroker.HookGlobalMouseEvents();

			HookBroker.MouseDown += (object s, MouseEventArgs eventArg) => { Console.WriteLine(eventArg.Button); };
			HookBroker.MouseWheel += (object s, MouseEventArgs eventArg) => { Console.WriteLine(eventArg.Delta); };
			HookBroker.MouseMove += (object s, MouseEventArgs eventArg) => { Console.WriteLine("Move : {0},{1}", eventArg.X, eventArg.Y); };

			this.StartButton.Enabled = false;
			this.StopButton.Enabled = true;
		}

		/// <summary>
		/// Stop 버튼이 클릭됐을 때 발생하는 이벤트를 구현한다.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void StopButton_Click(object sender, EventArgs e)
		{
			HookBroker.UnhookGlobalMouseEvents();

			this.StartButton.Enabled = true;
			this.StopButton.Enabled = false;
		}

		#endregion
	}
}
